﻿Imports System.Data.SqlClient

Public Class clsPagobus
    Private mintIdPagobus As Integer
    Private mdatFecha As Date
    Private mintIdAutobus As Integer
    Private mstrNoEconomico As String
    Private mintIdRuta As Integer
    Private mstrNombreRuta As String
    Private mdblPreferencial As Double
    Private mdblGeneral As Double
    Private mdblValidaciones As Double
    Private mdblIngresoPreferencial As Double
    Private mdblIngresoGeneral As Double
    Private mdblIngresoValidaciones As Double
    Private mdblImporte01 As Double
    Private mdblImporte02 As Double
    Private mdblImporte03 As Double
    Private mdblImporte04 As Double
    Private mdblImporte05 As Double
    Private mstrTexto01 As String
    Private mstrTexto02 As String
    Private mstrTexto03 As String
    Private mstrTexto04 As String
    Private mstrTexto05 As String
    Private mdblTerceraEdad As Double
    Private mdblImporteTerceraEdad As Double

    Public Property IdPagobus() As Integer
        Get
            Return mintIdPagobus
        End Get
        Set(ByVal value As Integer)
            mintIdPagobus = value
        End Set
    End Property
    Public Property Fecha As Date
        Get
            Return mdatFecha
        End Get
        Set(ByVal value As Date)
            mdatFecha = value
        End Set
    End Property
    Public Property IdAutobus() As Integer
        Get
            Return mintIdAutobus
        End Get
        Set(ByVal value As Integer)
            mintIdAutobus = value
        End Set
    End Property
    Public Property NoEconomico() As String
        Get
            Return mstrNoEconomico
        End Get
        Set(ByVal value As String)
            mstrNoEconomico = value
        End Set
    End Property
    Public Property IdRuta() As Integer
        Get
            Return mintIdRuta
        End Get
        Set(ByVal value As Integer)
            mintIdRuta = value
        End Set
    End Property
    Public Property NombreRuta() As String
        Get
            Return mstrNombreRuta
        End Get
        Set(ByVal value As String)
            mstrNombreRuta = value
        End Set
    End Property
    Public Property Preferencial() As Double
        Get
            Return mdblPreferencial
        End Get
        Set(ByVal value As Double)
            mdblPreferencial = value
        End Set
    End Property

    Public Property General() As Double
        Get
            Return mdblGeneral
        End Get
        Set(ByVal value As Double)
            mdblGeneral = value
        End Set
    End Property
    Public Property Validaciones() As Double
        Get
            Return mdblValidaciones
        End Get
        Set(ByVal value As Double)
            mdblValidaciones = value
        End Set
    End Property
    Public Property IngresoPreferencial() As Double
        Get
            Return mdblIngresoPreferencial
        End Get
        Set(ByVal value As Double)
            mdblIngresoPreferencial = value
        End Set
    End Property
    Public Property IngresoGeneral() As Double
        Get
            Return mdblIngresoGeneral
        End Get
        Set(ByVal value As Double)
            mdblIngresoGeneral = value
        End Set
    End Property
    Public Property IngresoValidaciones() As Double
        Get
            Return mdblIngresoValidaciones
        End Get
        Set(ByVal value As Double)
            mdblIngresoValidaciones = value
        End Set
    End Property
    Public Property Importe01() As Double
        Get
            Return mdblImporte01
        End Get
        Set(ByVal value As Double)
            mdblImporte01 = value
        End Set
    End Property
    Public Property Importe02() As Double
        Get
            Return mdblImporte02
        End Get
        Set(ByVal value As Double)
            mdblImporte02 = value
        End Set
    End Property
    Public Property Importe03() As Double
        Get
            Return mdblImporte03
        End Get
        Set(ByVal value As Double)
            mdblImporte03 = value
        End Set
    End Property
    Public Property Importe04() As Double
        Get
            Return mdblImporte04
        End Get
        Set(ByVal value As Double)
            mdblImporte04 = value
        End Set
    End Property
    Public Property Importe05() As Double
        Get
            Return mdblImporte05
        End Get
        Set(ByVal value As Double)
            mdblImporte05 = value
        End Set
    End Property
    Public Property Texto01 As String
        Get
            Return mstrTexto01
        End Get
        Set(value As String)
            mstrTexto01 = value
        End Set
    End Property
    Public Property Texto02 As String
        Get
            Return mstrTexto02
        End Get
        Set(value As String)
            mstrTexto02 = value
        End Set
    End Property
    Public Property Texto03 As String
        Get
            Return mstrTexto03
        End Get
        Set(value As String)
            mstrTexto03 = value
        End Set
    End Property
    Public Property Texto04 As String
        Get
            Return mstrTexto04
        End Get
        Set(value As String)
            mstrTexto04 = value
        End Set
    End Property
    Public Property Texto05 As String
        Get
            Return mstrTexto05
        End Get
        Set(value As String)
            mstrTexto05 = value
        End Set
    End Property
    Public Property TerceraEdad() As Double
        Get
            Return mdblTerceraEdad
        End Get
        Set(ByVal value As Double)
            mdblTerceraEdad = value
        End Set
    End Property
    Public Property ImporteTerceraEdad() As Double
        Get
            Return mdblImporteTerceraEdad
        End Get
        Set(ByVal value As Double)
            mdblImporteTerceraEdad = value
        End Set
    End Property
    Public Sub New()
        mintIdPagobus = 0
        mdatFecha = Now()
        mintIdAutobus = 0
        mstrNoEconomico = ""
        mintIdRuta = 0
        mstrNombreRuta = ""
        mdblPreferencial = 0
        mdblGeneral = 0
        mdblValidaciones = 0
        mdblIngresoPreferencial = 0
        mdblIngresoGeneral = 0
        mdblIngresoValidaciones = 0
        mdblImporte01 = 0
        mdblImporte02 = 0
        mdblImporte03 = 0
        mdblImporte04 = 0
        mdblImporte05 = 0
        mstrTexto01 = ""
        mstrTexto02 = ""
        mstrTexto03 = ""
        mstrTexto04 = ""
        mstrTexto05 = ""
        mdblTerceraEdad = 0
        mdblImporteTerceraEdad = 0
    End Sub
    Public Sub Insertar()
        Dim sql As String = "Insert Into Pagobus (" & _
                            "Fecha," & _
                            "IdAutobus," & _
                            "NoEconomico," & _
                            "IdRuta," & _
                            "NombreRuta," & _
                            "Preferencial," & _
                            "General," & _
                            "Validaciones," & _
                            "IngresoPreferencial," & _
                            "IngresoGeneral," & _
                            "IngresoValidaciones," & _
                            "Importe01," & _
                            "Importe02," & _
                            "Importe03," & _
                            "Importe04," & _
                            "Importe05," & _
                            "Texto01," & _
                            "Texto02," & _
                            "Texto03," & _
                            "Texto04," & _
                            "Texto05, " & _
                            "TerceraEdad," & _
                            "ImporteTerceraEdad)" & _
                            "VALUES (" & _
                            "@Fecha," & _
                            "@IdAutobus," & _
                            "@NoEconomico," & _
                            "@IdRuta," & _
                            "@NombreRuta," & _
                            "@Preferencial," & _
                            "@General," & _
                            "@Validaciones," & _
                            "@IngresoPreferencial," & _
                            "@IngresoGeneral," & _
                            "@IngresoValidaciones," & _
                            "@Importe01," & _
                            "@Importe02," & _
                            "@Importe03," & _
                            "@Importe04," & _
                            "@Importe05," & _
                            "@Texto01," & _
                            "@Texto02," & _
                            "@Texto03," & _
                            "@Texto04," & _
                            "@Texto05, " & _
                            "@TerceraEdad," & _
                            "@ImporteTerceraEdad)"


        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("Fecha", mdatFecha)
        Command.Parameters.AddWithValue("IdAutobus", mintIdAutobus)
        Command.Parameters.AddWithValue("NoEconomico", mstrNoEconomico)
        Command.Parameters.AddWithValue("IdRuta", mintIdRuta)
        Command.Parameters.AddWithValue("NombreRuta", mstrNombreRuta)
        Command.Parameters.AddWithValue("Preferencial", mdblPreferencial)
        Command.Parameters.AddWithValue("General", mdblGeneral)
        Command.Parameters.AddWithValue("Validaciones", mdblValidaciones)
        Command.Parameters.AddWithValue("IngresoPreferencial", mdblIngresoPreferencial)
        Command.Parameters.AddWithValue("IngresoGeneral", mdblIngresoGeneral)
        Command.Parameters.AddWithValue("IngresoValidaciones", mdblIngresoValidaciones)
        Command.Parameters.AddWithValue("Importe01", mdblImporte01)
        Command.Parameters.AddWithValue("Importe02", mdblImporte02)
        Command.Parameters.AddWithValue("Importe03", mdblImporte03)
        Command.Parameters.AddWithValue("Importe04", mdblImporte04)
        Command.Parameters.AddWithValue("Importe05", mdblImporte05)
        Command.Parameters.AddWithValue("Texto01", mstrTexto01)
        Command.Parameters.AddWithValue("Texto02", mstrTexto02)
        Command.Parameters.AddWithValue("Texto03", mstrTexto03)
        Command.Parameters.AddWithValue("Texto04", mstrTexto04)
        Command.Parameters.AddWithValue("Texto05", mstrTexto05)
        Command.Parameters.AddWithValue("TerceraEdad", mdblTerceraEdad)
        Command.Parameters.AddWithValue("ImporteTerceraEdad", mdblImporteTerceraEdad)

        cnConn.Open()
        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar el registro de Pagobus ", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub

End Class
